<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php
	/*
	 * Print the <title> tag based on what is being viewed.
	 */
	global $page, $paged;

	wp_title( '|', true, 'right' );

	// Add the blog name.
	bloginfo( 'name' );

	// Add the blog description for the home/front page.
	$site_description = get_bloginfo( 'description', 'display' );
	if ( $site_description && ( is_home() || is_front_page() ) )
		echo " | $site_description";

	// Add a page number if necessary:
	if ( $paged >= 2 || $page >= 2 )
		echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );

	?></title>
<script type="text/javascript">
document.title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>";
</script>
<!--[if gt IE 7]><meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible" /><![endif]-->
<link rel="shortcut icon" href="http://casamenteiras.com.br/favicon.ico" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<script type="text/javascript">if ( ! window.jQuery ) document.write('<scr'+'ipt type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></scr'+'ipt>')</script>
<?php
	/* We add some JavaScript to pages with the comment form
	 * to support sites with threaded comments (when in use).
	 */
	if ( is_singular() && get_option( 'thread_comments' ) )
		wp_enqueue_script( 'comment-reply' );

	/* Always have wp_head() just before the closing </head>
	 * tag of your theme, or you will break many plugins, which
	 * generally use this hook to add elements to <head> such
	 * as styles, scripts, and meta tags.
	 */
	wp_head();
?>
</head>
<?php flush(); ?>

<body <?php body_class(); ?>>
<?php
	if ($top = helper::adrotate('top')) {
		echo "".
		"<div id=\"publicidade-super\">".
			"<div id=\"publicidade-super-miolo\">".
				$top.
			"</div>".
		"</div>";
	}
	unset($top);
?>
<div id="wrapper" class="hfeed">
	<div id="header">
		<div id="masthead">
		
			<div id="branding" role="banner">
				<<?php echo $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div';; ?> id="site-title">
					<span>
						<?php
						$internal = helper::get_option('tema_casamenteiras_imagens', 'logo-internal');
						if ($heading_tag === 'h1' || ($heading_tag === 'div' && ! $internal)) {
							$logo = helper::get_option('tema_casamenteiras_imagens', 'logo', get_bloginfo('template_url').'/images/logo.png');
						} else {
							$logo = $internal;
						}
						?>
						<a href="/" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home" style="background-image: url('<?php echo $logo ?>');"><?php bloginfo( 'name' ); ?></a>
					</span>
				</<?php echo $heading_tag; ?>>
				
				<?php echo helper::social_nav(); ?>
				
				<div id="menu-top" role="navigation">
					<?php wp_nav_menu( array( 'container_class' => 'header-white', 'theme_location' => 'menu_branco' ) ); ?>
				</div><!-- #menu-top -->
				
				<div id="access" role="navigation">
				  <?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
					<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
					<?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu.  The menu assiged to the primary position is the one used.  If none is assigned, the menu with the lowest ID is used.  */ ?>
					<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'menu_azul' ) ); ?>
				</div><!-- #access -->
				<?php
					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
					if ( is_singular() && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ( $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && $image[1] >= HEADER_IMAGE_WIDTH ) :
						// Houston, we have a new header image!
						echo get_the_post_thumbnail( $post->ID );
					elseif( ( is_front_page() || is_home() ) && get_header_image() ) : ?>
						<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
					<?php
					endif;
					unset($opt_val);
					?>
			</div><!-- #branding -->
			
			<?php
			if(is_front_page() || is_home()) {
				
				$slideshow_options = get_option('tema_casamenteiras_home_posts');
				
				if ( ! isset($slideshow_options['highlight-actived']) || $slideshow_options['highlight-actived'] == 1 ) :
			?>
			<div id="banner">
				<ul id="featured">
					<?php
						$count = 1;
						$dotCount = 1;

						query_posts('cat='.((isset($slideshow_options['highlight-category']))?$slideshow_options['highlight-category']:1).'&showposts=5');
						while (have_posts()) : the_post();
							?>
							<li class="slide slide<?php echo $count; ?>">
								<img src="<?php echo get_banner_image($post->ID, "960","270"); ?>" alt="<?php the_title() ?>" class="image" />										
								<span class="fadeOverlay"></span>
								<p class="credit"><?php echo get_post_meta($post->ID, "bannerImageCredit", true); ?></p>
								<blockquote>
									<?php
										if ($slideshow = helper::adrotate('slideshow')) {
											echo "".
											"<div id=\"publicidade-slideshow\">".
												$slideshow.
											"</div>";
										}
										unset($slideshow);
									?>
									<h4><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_title() ?></a></h4>
									<p class="excerpt"><?php smallerexcerpt('25'); ?></p>
									<p class="readmore"><a href="<?php the_permalink() ?>" class="button">Mais</a></p>
								</blockquote>
							</li>
							<?php
							$count++;
						endwhile;
						wp_reset_query();
						$dotCount = $count - 1;
					?>
				</ul>
				<ul class="dots featuredDots show<?php echo $dotCount; ?>">
					<li class="active dot dot1"><a href="#"></a></li>
					<?php for ($i=2; $i<=$dotCount; $i++) : ?>
						<li class="dot dot<?php echo $i ?>"><a href="#"></a></li>
					<?php endfor; ?>
				</ul>
			</div>
			<?php
				endif;
			} elseif ( is_category() ) {
				$opt_val = get_option('tema_casamenteiras_padrao_categoria');
				$cats = get_the_category();
				$cats_id = array();
				foreach($cats as $cat) {
					array_push($cats_id, $cat->cat_ID);
				};
				while(count($cats_id) > 0) {
					$cat = array_pop($cats_id);
					if (isset($opt_val['image-'.$cat])) {
						break;
					} else {
						unset($cat);
						continue;
					};
				};
				if (isset($cat)) {
					echo '<img id="category-header" src="'.$opt_val['image-'.$cat].'" width="960" height="200" alt="" /><style>body {background:#'.$opt_val['color-'.$cat].' !important}</style>';
				} elseif (isset($opt_val['image-default'])) {
					echo '<img id="category-header" src="'.$opt_val['image-default'].'" width="960" height="200" alt="" />';
				};
			} else { ?>
				<?php if(is_archive()) { ?>
				<?php
				$opt_val = get_option('tema_casamenteiras_padrao_categoria');
				if (isset($opt_val['image-default'])) {
					echo '<img id="category-header" src="'.$opt_val['image-default'].'" width="960" height="200" alt="" />';
				} else {
				?>
				<div id="innerbanner">
					<div class="inner">
						<div class="left">
							<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
							<?php /* If this is a category archive */ if (is_category()) { ?>
							<h2 class="pagetitle"><?php single_cat_title(); ?></h2>
							<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
							<h2 class="pagetitle"><?php single_tag_title(); ?></h2>
							<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
							<h2 class="pagetitle"><?php the_time('j \d\e F \d\e Y'); ?></h2>
							<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
							<h2 class="pagetitle"><?php the_time('F \d\e Y'); ?></h2>
							<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
							<h2 class="pagetitle"><?php the_time('Y'); ?></h2>
							<?php /* If this is an author archive */ } elseif (is_author()) { ?>
							<h2 class="pagetitle">Arquivos do Autor</h2>
							<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
							<h2 class="pagetitle">Arquivos</h2>
							<?php } ?>
							<p><?php category_description(); ?></p>
						</div>
						<div class="right"></div>
					</div>
				</div>
				<?php } ?>
				<?php } ?>
				<?php if(is_search()) { ?>
				<?php
				$opt_val = get_option('tema_casamenteiras_padrao_categoria');
				if (isset($opt_val['image-default'])) {
					echo '<img id="category-header" src="'.$opt_val['image-default'].'" width="960" height="200" alt="" />';
				} else {
				?>
				<div id="innerbanner"><div class="inner">
					<div class="left">
						<h2>Resultados da Busca para "<?php echo $_GET['s']; ?>"</h2>
					</div>
					<div class="right"></div>
				</div>
				<?php } ?>
				<?php } ?>
				<?php if(is_single()) { ?>
				<?php
				$opt_val = get_option('tema_casamenteiras_padrao_categoria');
				if (isset($opt_val['image-default'])) {
					echo '<img id="category-header" src="'.$opt_val['image-default'].'" width="960" height="200" alt="" />';
				} else {
				?>
				<div id="innerbanner" style="background:url(<?php echo get_banner_image($post->ID, "960","270"); ?>) no-repeat;">
					<div class="inner">
						<div class="left">
							<h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
							<p>Publicado dia <?php the_time('j \d\e F \d\e Y'); ?><br />Na(s) categoria(s) <?php the_category(', '); ?></p>
						</div>
					</div>
				</div>
				<?php } ?>
				<?php } ?>
				<?php if(is_page()) { ?>
				<?php
				$opt_val = get_option('tema_casamenteiras_padrao_categoria');
				if (isset($opt_val['image-default'])) {
					echo '<img id="category-header" src="'.$opt_val['image-default'].'" width="960" height="200" alt="" />';
				} else {
				?>
				<div id="innerbanner" style="background:url(<?php echo $bannerImage; ?>) no-repeat;">
					<div class="inner">
						<div class="left">
							<h2><?php the_title(); ?></h2>
							<p><?php echo get_post_meta($post->ID, "pageDescription", true); ?></p>
						</div>
					</div>
				</div>
				<?php } ?>
				<?php } ?>
			<?php } ?>
			<div id="breadcrumb">
				<p class="breadcrumb"><?php yoast_breadcrumb(); ?></p>
				<div id="search">
					<?php get_search_form(); ?>
				</div>
			</div><!-- #breadcrumb -->
			
		</div><!-- #masthead -->
	</div><!-- #header -->
	<div class="clear">&nbsp;</div>

	<div id="main">